package org.chipu.jnids;

import sun.util.calendar.BaseCalendar;
import sun.util.calendar.CalendarSystem;

import java.util.*;

public class PerformanceTester {
	/** @see GregorianCalendar#computeFields */
	public static void main(String[] args) {
		Calendar c = Calendar.getInstance();
		c.setTimeInMillis(((long) 1206460800) * 1000);
		Short id = (short) ((c.get(Calendar.DAY_OF_WEEK) << 5) + c.get(Calendar.HOUR_OF_DAY));
		System.out.println(1206460800 + " " + new Date(1206460800l * 1000));
		System.out.println(id);

		BaseCalendar.Date calendarDate = CalendarSystem.getGregorianCalendar().newCalendarDate(
			TimeZone.getDefault());
		TimeZone tz = Calendar.getInstance().getTimeZone();
		long ONE_DAY = 24 * 60 * 60 * 1000;
		long fixedDate = zoneOffset / ONE_DAY;
		int timeOfDay = zoneOffset % (int) ONE_DAY;
		fixedDate += time / ONE_DAY;
		timeOfDay += (int) (time % ONE_DAY);
		if (timeOfDay >= ONE_DAY) {
			timeOfDay -= ONE_DAY;
			++fixedDate;
		} else {
			while(timeOfDay < 0) {
				timeOfDay += ONE_DAY;
				--fixedDate;
			}
		}
		fixedDate += EPOCH_OFFSET;
		CalendarSystem.getGregorianCalendar().getCalendarDateFromFixedDate(calendarDate, fixedDate);
	}
}